package xyz.xxpc.springcloud.consumer.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.xxpc.springcloud.consumer.service.UserFeignService;
import xyz.xxpc.springcloud.pojo.User;
import xyz.xxpc.springcloud.service.api.UserService;

import java.util.List;

@RestController
@RequestMapping("/feign")
public class UserFeignController {

    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }


    @GetMapping("/all")
    public List<User> queryAll() throws InterruptedException {
        return  userService.queryAll();
    }
    @GetMapping("/{id}")
    public User query(@PathVariable("id") Integer id){
        return  userService.query(id);
    }

    @PostMapping("/add")
    public User add(@RequestBody User user){
        return  userService.add(user);
    }
}
